# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from rest_framework.generics import GenericAPIView, CreateAPIView
from django.shortcuts import render
from .serializers import UserSerializer

# Create your views here.
from rest_framework.response import Response

from users.models import User


class UserNameView(GenericAPIView):
    def get(self,request,username):
        count = User.objects.filter(username=username).count()
        return Response({
            "username":username,
            "count":count
        })
class MobileView(GenericAPIView):
    def get(self,request,mobile):
        count = User.objects.filter(mobile=mobile).count()
        return Response({
            "mobile":mobile,
            "count":count
        })

class UserView(CreateAPIView):
    serializer_class =UserSerializer
